package me.controller;

import me.domain.Student;
import me.service.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 展示首页信息的controller
 *
 * @author Rainh
 */
@Controller
public class IndexController {

    //实例化studentService对象
//    private StudentService studentService = new StudentServiceImpl();

    @Resource(name = "studentService")
    private StudentService studentService;

    @RequestMapping("/indexController")
    public String index(HttpSession session){
        //获取所有的学生信息
        List<Student> studentList = studentService.getAllStudents();
        //保存在session中
        session.setAttribute("STUDENT_LIST",studentList);
        //返回index页面
        return "index";
    }

}
